import React, { Component } from 'react'
import * as action from '../redux/ancion'
import {connect} from 'react-redux'
class Home extends Component {
  constructor(props){
    super(props)

  }
  handClick = () => {
    this.props.update({name:'xinnnnnn'});
  }
  render() {
    console.log(this.props)
    return (
      <div>
        home
        {this.props.information[0].name}
        <button onClick={this.handClick}>修改store中的名字</button>
      </div>
    )
  }
}

const mapStateToProps = (state) => {
  return{
    information:state.data
  }
}
const mapDispatchToProps = (dispatch) => {
  return{
    update:(newinfo)=>{dispatch(action.updateInfor(newinfo))}
  }
}
export default connect(mapStateToProps, mapDispatchToProps)(Home)